<template>
  <div class="Timeline">
    <!--视频弹窗-->
    <el-dialog :title="popTitle" v-if="videoShow" v-model="videoShow">
      <el-row>
        <el-col :span="24">
          <div v-html="videoURL"></div>
        </el-col>
      </el-row>
    </el-dialog>
    <!--音频弹窗-->
    <el-dialog :title="popTitle" v-if="audioShow" v-model="audioShow">
      <el-row>
        <el-col :span="24">
          <div v-html="audioURL"></div>
        </el-col>
      </el-row>
    </el-dialog>
    <!--图片弹窗-->
    <el-dialog :title="popTitle" v-if="imgShow" v-model="imgShow">
      <el-row>
        <el-col :span="24">
          <div v-html="imgURL"></div>
        </el-col>
      </el-row>
    </el-dialog>
    <!--自学任务单弹窗-->
    <el-dialog size="large" :title="popTitle" v-if="taskShow" v-model="taskShow">
      <el-row>
        <el-col :span="24">
          <taskList :taskList="taskData"></taskList>
        </el-col>
      </el-row>
    </el-dialog>
    <!--PPT弹窗-->
    <el-dialog size="full" :title="popTitle" v-if="pptShow" v-model="pptShow">
      <el-row>
        <el-col :span="24">
          <ppt :imgList="pptData"></ppt>
        </el-col>
      </el-row>
    </el-dialog>
    <!--单试题弹窗-->
    <transition enter-active-class="animated zoomIn">
      <shiti :QuestionDATA="Question" :ExamParam="examParam" v-if="ReTypeCode=='RE0011'" :showModel="ReTypeCode=='RE0011'"></shiti>
    </transition>
    <!--测试-->
    <transition enter-active-class="animated zoomIn">
      <classTest :QuestionDATA="Question" :ExamParam="examParam" v-if="ReTypeCode=='RE0009'||ReTypeCode=='RE0010'" :showModel="ReTypeCode=='RE0009'||ReTypeCode=='RE0010'"></classTest>
    </transition>
  </div>
</template>

<script type="text/ecmascript-6">
import shiti from './shiti.vue'
import ppt from './PPT/PPT.vue'
import classTest from './classTest.vue'
import store from '../../store'
import AnswerHelper from '../../assets/js/AnswerHelper.js'
export default {
  name: 'main',
  watch: {
    '$route'(to, from) {
      this.loadRes(to.params.ResourceID)
      // console.log('从' + from.params.ResourceID + '到' + to.params.ResourceID);
    }
  },
  mutated: {},
  components: {
    shiti,
    classTest,
    ppt
  },
  data() {
    var _this = this;
    return {
      examParam:[],
      pptData: [],
      taskData: [],
      ReTypeCode: '',
      TechType: 0,
      videoShow: false,
      audioShow: false,
      imgShow: false,
      pptShow: false,
      taskShow: false,
      videoURL: "",
      audioURL: "",
      imgURL: "",
      shitiTitle: "",
      Question: {},//试题
      popTitle: ""
    }
  },
  mounted() {
    this.loadRes(this.$route.params.ResourceID)
  },
  methods: {
    loadRes(resId) {
      var _this = this;
      AnswerHelper.ReSetAnswer()
      _this.$route.params['ArrangeID']=0
      _this.$route.params['VoteID']='199011221535'
      _this.$route.params['LessionID']=756
      _this.$route.params['TeacherID']=163
      _this.$route.params['ExamID']='a9bf9063-f1cb-4f6e-82e1-36cb528d220a'
      _this.$route.params['BeginTeachingTime']='636305255870000000'
      _this.$route.params['ServerIP']='http://127.0.0.1:87556'

      _this.examParam=_this.$route.params
      //加载资源
      _this.$http.get('api/resource/get?ids=' + resId + "&sk=" + _this.$store.state.token).then(function (res) {

        store.state.resource = res.data.data
        _this.ReTypeCode = res.data.data[0].ReTypeCode
        //课件--PPT
        if (res.data.data[0].ReTypeCode === "RE0001") {
          _this.popTitle = res.data.data[0].ReOrginName
          _this.pptData = res.data.data[0].child
          console.log(_this.pptData)
        }
        //自学任务单
        if (res.data.data[0].ReTypeCode === "RE0003") {
          _this.popTitle = res.data.data[0].ReOrginName
          _this.taskData = res.data.data[0].child
        }
        //素材 判断素材类型
        if (res.data.data[0].ReTypeCode === "RE0013") {
          _this.TechType = res.data.data[0].TechType
          if (res.data.data[0].TechType === 0) {//视频资源
            _this.videoURL = "<video style='width: 100%' controls='controls' src=" + store.state.config.resourceURL + res.data.data[0].ResourceName + "></video>"
            _this.popTitle = res.data.data[0].ReOrginName
          } else if (res.data.data[0].TechType === 5) {//音频资源
            _this.audioURL = "<audio style='width: 100%' controls='controls' src=" + store.state.config.resourceURL + res.data.data[0].ResourceName + "></audio>"
            _this.popTitle = res.data.data[0].ReOrginName
          } else if (res.data.data[0].TechType === 1) {//图片资源
            _this.imgURL = "<img style='width: 100%' src=" + store.state.config.resourceURL + res.data.data[0].ResourceName + "></img>"
            _this.popTitle = res.data.data[0].ReOrginName
          }
        }
        //题型 判断不同题型类型
        if (res.data.data[0].ReTypeCode === "RE0011") {
          //更改试题title
          _this.shitiTitle = res.data.data[0].child.QuestionRemark
          //试题具体信息
          _this.Question = res.data.data[0]
          console.log(_this.Question)

          //显示试题弹窗

          //试题类型
          //题型(QuestionTypeCode)：
          //单选 QUE0003
          //多选 QUE0007 => QUE0037
          //阅读理解 QUE0008
          //主观题 QUE0042
          //复合题 QUE0043
          //图文匹配题 QUE0046
          //归类题 QUE0049
          //文字排序题 QUE0138
          //图片排序题 QUE0139
          //文字连线题 QUE0140
          //图片连线题 QUE0141
          //听力判断题 QUE0143
          //听力文字连线题 QUE0145
          //听力图片连线题 QUE0146
          //判断题 QUE0142
          //听力单项选择 QUE0147
          _this.Question.QuestionTypeCode = res.data.data[0].child.QuestionTypeCode
        }
        //组合，测试，作业
        if (res.data.data[0].ReTypeCode === "RE0009" || res.data.data[0].ReTypeCode === "RE0010") {
          //更改试题title
          _this.shitiTitle = res.data.data[0].child.QuestionRemark
          //试题具体信息
          _this.Question = res.data.data[0]
          console.log(_this.Question)

          //显示试题弹窗
          _this.Question.QuestionTypeCode = res.data.data[0].child.QuestionTypeCode
        }

        _this.videoShow = _this.ReTypeCode == 'RE0013' && _this.TechType == 0
        _this.audioShow = _this.ReTypeCode == 'RE0013' && _this.TechType == 5
        _this.imgShow = _this.ReTypeCode == 'RE0013' && _this.TechType == 1
        _this.pptShow = _this.ReTypeCode == 'RE0001'
        _this.taskShow = _this.ReTypeCode == 'RE0003'

      })
    }
  }
}
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
.Timeline {
  height: 100%;
  position: relative;
  /*overflow-x: hidden;*/
  /*overflow-y: auto;*/
}

.Timeline::-webkit-scrollbar {
  width: 0px
}

.el-dialog {
  background: #000;
}

.kapian {
  cursor: pointer;
}

.popVideo {
  width: 100%;
}

.title {
  margin-bottom: 14px;
}

.card-item {
  margin-bottom: 14px;
}
</style>
